import {getSysuser, editSysuser, addSysuser, deleteSysuser, resetPassword, getSysuserDetail,
    getSysroles, getSysrolesDetail, editSysroles, addSysroles, deleteSysroles, getUserAuth, checkSysuser, checkSysroles, unlockAccount, underCustId,
    roleEditorDetail, saveRoleEditor
} from '@/api/systemApi'
const system = {
    namespaced: true,
    state: {
    },
    getters: {},
    mutations: {
    },
    actions: {
        // 获取用户列表
        GetSysuser ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getSysuser(params).then(res => {
                    resolve(res)
                }).catch(error => {
                    reject(error)
                })
            })
        },
        // 用户详情
        GetSysuserDetail ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getSysuserDetail(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 编辑用户
        EditSysuser ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                editSysuser(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 用户新增
        AddSysuser ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                addSysuser(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 用户删除
        DeleteSysuser ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                deleteSysuser(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 密码重置
        ResetPassword ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                resetPassword(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色列表
        GetSysroles ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getSysroles(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色详情
        GetSysrolesDetail ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getSysrolesDetail(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色编辑
        EditSysroles ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                editSysroles(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色新增
        AddSysroles ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                addSysroles(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色新增
        DeleteSysroles ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                deleteSysroles(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 用户权限
        GetUserAuth ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                getUserAuth(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 用户名是否存在
        CheckSysuser ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                checkSysuser(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 角色名称是否存在
        CheckSysroles ({state, commit, dispatch}, params) {
          return new Promise((resolve, reject) => {
              checkSysroles(params).then(res => {
                  resolve(res)
              })
          })
        },
        // 解锁账号
        UnlockAccount ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              unlockAccount(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 代理范围
        UnderCustId ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
              underCustId(params).then(res => {
                    resolve(res)
                })
            })
        },
        // 代理范围
        RoleEditorDetail ({state, commit, dispatch}, roleId) {
            return new Promise((resolve, reject) => {
                roleEditorDetail(roleId).then(res => {
                    resolve(res)
                })
            })
        },
        // 代理范围
        SaveRoleEditor ({state, commit, dispatch}, params) {
            return new Promise((resolve, reject) => {
                saveRoleEditor(params).then(res => {
                    resolve(res)
                })
            })
        }
    }
}
export default system
